<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="{$CND_URL}/{$TMPL_PATH}Public/js/jquery.js"></script>
<script type="text/javascript">
{if $smarty.session.user_id == null}
    alert('请选登陆');
    parent.location.href='./';
{/if}
   // $(document).ready(function(){

		function openNote(number){
                        $("#glassNote").show('slow',function(){
                            $.ajax({
                              type:'POST',
                              url: '?m=goods&a=game&action=glass&good_id={$good_id}&number='+number,
                              success:  function(data){
                                  if(data == 4){
                                      $("#glassMsgList").html('此号码没有人购买');
                                  }else if(data == 0){
                                      alert('请先登陆');
                                  }else if(data == 2){
                                      alert('积分不够');
                                  }
                                  else{
                                      var jsonData=eval(data);  
                                      var htmlCode=''
                                        $.each(jsonData,  function(i, n){
                                            $.each(n,function(c,b){
                                                //alert(c+'|'+b);
                                                htmlCode += b+'购买了此数字 | <a href="javascript:void(0);" id="bombit" alt="'+c+'">使用炸弹</a> | <a href="javascript:void(0);" id="sheildit" alt="'+c+'">使用盾牌</a><br/>';
                                            });
                                        }); 
                                        $("#glassMsgList").html(htmlCode);
                $("#glassMsgList a").click(function(){
                    var id = $(this).attr("alt");
                    var action = $(this).attr("id");
                    //alert(id);
                    bomborsheild(action,id);
                });
function bomborsheild(action,id){
//    alert(action+id);
    var note;
    switch (action) {
        case 'bombit':
        note = '炸掉';
        break;
        case 'sheildit':
        note = '保护';
        break;
        
    }
    var r=confirm("您确定"+note+"这个数字吗？") 
    if (r==true) {
        $.ajax({
                  type:'get',
                  url: '?m=goods&a=game&action='+action+'&good_id={$good_id}&id='+id,
                  success:  function(data){
//                      alert(data);
                      if(data == '0'){
                          alert('请先登陆');
                      }else if(data =='1'){
                          alert('操作成功');
                          window.location.reload();
                      }


                    },
                  dataType: 'html'
                });
    }
}
                                  }
                                  
                              },
                              dataType: 'html'
                            });
                        });
		}
                
                
                

function display_confirm(action,number){   
var action;
var note;
var note2 = '';
var number;
    switch (action) {
            case 'bid':
            note = '购买';
            break;
            case 'bomb':
            note = '炸掉';
            break;
            case 'sheild':
            note = '保护';
            break;
            case 'glass':
            note = '查看';
            note2= '眼镜使用一次只能查看一次';
            break;
    }
     
  var r=confirm("您确定"+note+"这个数字吗？"+note2)   
  if (r==true)   
    {   
	if(action=='glass'){
            openNote(number);
        }else{
            $(document).ready(function(){
                $.ajax({
                  type:'get',
                  url: '?m=goods&a=game&action='+action+'&good_id={$good_id}&number='+number,
                  success:  function(data){
//                      alert(data);
                      if(data == '0'){
                          alert('请先登陆');
                      }else if(data =='1'){
                          alert('操作成功');
                          window.location.reload();
                      }else if(data =='2'){
                          alert('积分不够');
                      }else if(data =='3'){
                          alert('此号码您已经购买过，不能重复购买');
                      }else if(data =='10'){
                          window.location.reload();
                      }


                    },
                  dataType: 'html'
                });
         });
	}
    } 
  } 
 // });
  /////////////////
	var htmlCode='';
	for(var i = 1 ; i <= 100 ; i++ ){
		htmlCode += '<div class="num" id="num'+i+'"><div id="bomb'+i+'"><div id="sheild'+i+'"><a href="javascript:void(0);" onclick="display_confirm(\'{$model}\',\''+i+'\')">'+i+'</a></div></div></div>';
		}
                htmlCode += '<div id="clear"></div>';
	$(document).ready(function(){
        
        function model(chmodel){
            $.post("?m=goods&a=game&action=model",{model:chmodel},function(result){
            window.location.reload();
            });
        }
        function pic(id){
            $("#"+id+" img").attr("src", "{$CND_URL}/{$TMPL_PATH}Public/images/"+id+"-on.gif");
        }
        $("#bid").click(function(){
            var chmodel = $(this).attr("id");
            pic(chmodel);
            model(chmodel);
        });
        $("#bomb").click(function(){
            var chmodel = $(this).attr("id");
            pic(chmodel);
            model(chmodel);
        });
        $("#sheild").click(function(){
            var chmodel = $(this).attr("id");
            pic(chmodel);
            model(chmodel);
        });
        $("#glass").click(function(){
            var chmodel = $(this).attr("id");
            pic(chmodel);
            model(chmodel);
        });
        pic('{$model}');
	$("#closeGlassNote").click(function(){
            var r=confirm("关闭后不能再次查看，你确定吗？")   
            if (r==true){
                window.location.reload();
                $("#glassNote").hide('slow');
            }
            
            });
		
		
		$("#numRow").html(htmlCode);
                {foreach from=$bided item=bid }
                $("#num{$bid.number}").css("backgroundImage","url({$CND_URL}/{$TMPL_PATH}Public/images/bid.gif)"); 
                {/foreach}
		{foreach from=$bombed item=bombed }
                $("#bomb{$bombed.number}").css({"backgroundImage":"url({$CND_URL}/{$TMPL_PATH}Public/images/bomb.gif)"}); 
                {/foreach}
                {foreach from=$sheild item=sheild }
                $("#sheild{$sheild.number}").css({"backgroundImage":"url({$CND_URL}/{$TMPL_PATH}Public/images/sheild.gif)"}); 
                {/foreach}
	});
	
	
</script>
<style>
a:link {
	color: #333;
	text-decoration: none;
}
a:visited {
	text-decoration: none;
	color: #666;
}
a:hover {
	text-decoration: none;
	color: #000;
}
a:active {
	text-decoration: none;
	color: #666;
}
.game ul{ padding-top:30px;}
#clear{ clear:both; height:0; overflow:hidden;}
.game .right .num{ width:40px; height:40px; float:left; margin:0 22px 6px 0; background:#F2F2F2; text-align:center;}
.game .right .num a{ padding:10px; line-height:40px; text-align:center;}
.game .right .num a:hover{color:#cccccc;}
img{ border:0;}
body,td,th {
	font-size: 12px;
}
.note{position:absolute; width: 100px; height: 0px; background:#333; display:none;}
</style>
</head>

<body>
<div style="position:absolute; width:530px; height:380px; background:#fff; display:none; z-index:10; margin:40px 0 0 320px; border:  #000 10px solid;" id="glassNote">
    <span style="color:  tomato;">眼镜使用一次只能查看一次</span><span style=" float:right;"><a href="javascript:void(0);" id="closeGlassNote">关闭</a></span>
    <div id="glassMsgList"></div>
</div>
<div style=" width: 950px; height: 500px; " class="game">
        <div style="float: left; width: 300px;">
        <div class="bid"><a href="javascript:void(0);" id="bid"><img src="{$CND_URL}/{$TMPL_PATH}Public/images/bid-off.gif" width="160" height="60"  /></a></div>
        <div class="bomb"><a href="javascript:void(0);" id="bomb"><img src="{$CND_URL}/{$TMPL_PATH}Public/images/bomb-off.gif" width="160" height="60"  /></a></div>
        <div class="sheild"><a href="javascript:void(0);" id="sheild"><img src="{$CND_URL}/{$TMPL_PATH}Public/images/sheild-off.gif" width="160" height="60"  /></a></div>
        <div class="glass"><a href="javascript:void(0);" id="glass"><img src="{$CND_URL}/{$TMPL_PATH}Public/images/glass-off.gif" width="160" height="60"  /></a></div>
        您还有{$score}积分
        <div style="background:url({$CND_URL}/{$TMPL_PATH}Public/images/newsroll-bg.gif) no-repeat; width:290px; height:228px;">
<ul style=" margin: 0; padding: 22px 0 0 33px;">
            {foreach from=$gamelog item=value }
        <li>{$value.tips}[{$value.dateline}]</li>
        {/foreach}
        </ul>
        </div>
        </div>
<div style="float: left; width: 650px;  margin-top:15px;" class="right" id="numRow">
  </div>
</div>

    
</body>
</html>
